﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;

namespace NebimXml
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
        }
            StreamWriter write;
        private void button1_Click(object sender, EventArgs e)
        {
#region Optionlar.mml

            write = new StreamWriter("optionlar.xml");
            
            write.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            write.WriteLine("<opsiyonlar>");

            IQueryable<tbBedenTipi> item = Option.BedenTipi.BTipi();

            foreach (tbBedenTipi str in item)
            {
                if (str.sBedenTipi.ToString()!="   ")
                {
                    // MessageBox.Show(str.sAciklama.ToString());
                    write.WriteLine("<option>");
                    write.WriteLine(string.Format("<kod>{0}</kod>", str.sBedenTipi));
                    write.WriteLine(string.Format("<tanim>{0}</tanim>", str.sBedenTipi));
                    write.WriteLine(string.Format("<bilgi>{0}</bilgi>", str.sAciklama));
                    write.WriteLine("<secenekler>");
                    if (str.sBeden1.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden1));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden1));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden2.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden2));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden2));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden3.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden3));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden3));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden3.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden3));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden3));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden4.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden4));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden4));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden5.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden5));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden5));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden6.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden6));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden6));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden7.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden7));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden7));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden8.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden8));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden8));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden9.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden9));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden9));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden10.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden10));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden10));
                        write.WriteLine("</secenek>");
                    }
                    if (str.sBeden11.ToString()!="   ")
                    {
                        write.WriteLine("<secenek>");
                        write.WriteLine(string.Format("<sec_kod>{0}</sec_kod>", str.sBeden11));
                        write.WriteLine(string.Format("<sec_tanim>{0}</sec_tanim>", str.sBeden11));
                        write.WriteLine("</secenek>");
                    }
                    write.WriteLine("</secenekler>");
                    write.WriteLine("</option>");
                }
            }
            write.WriteLine("</opsiyonlar>");

            write.Close();

            MessageBox.Show("jj");
#endregion
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            

        }
    }
}
